<%@page import="com.solution.admin.order.constants.OrderConstants"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sl" tagdir="/WEB-INF/tags" %>
<%@page import="com.solution.common.config.PublicConfig"%>
<%@page import="com.solution.common.constants.PublicStatus"%>
<%@page import="com.solution.admin.home.constants.IndexConstants"%>
<%
	String basePath = PublicConfig.ROOT_PATH;
	String imgRootURL = PublicConfig.IMG_ROOT_URL;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>签收</title>
<link rel="stylesheet" type="text/css" href="<%=basePath%>/statics_wx/css/style.css">
<script src="<%=basePath%>/statics_wx/js/jquery.min.js"></script>
<script src="<%=basePath%>/statics_wx/js/js.js"></script>
<script type="text/javascript" src="<%=basePath%>/statics/plugins/layer/layer.js"></script>
<script type="text/javascript">
	//系统域名 
	var rootPath = '<%=basePath%>';
	// 系统上传文件展示域名
	var imgRootURL = '<%=imgRootURL%>';
</script>
<style>
.prd_list1 ul li .box5 .good_info11 .item-info h4 strong{color:#333}
</style>
<script>
$(function(){
	
	var order_code = "";
	var delivery_code = "";
	var delivery_bill_id = "";
	$("a[id='btn_order_sign']").each(function(){
		$(this).click(function(){
			$("#del_box").toggle();
			order_code = $(this).parent().find("#order_code").val();
			delivery_code = $(this).parent().find("#delivery_code").val();
			delivery_bill_id = $(this).parent().find("#delivery_bill_id").val();
		});
	});
	
	$("#btn_confirm_sign").click(function(){
		var url = rootPath + "/wx/order/confirmSign";
		var params = {
			orderCode : order_code,
			deliveryCode : delivery_code,
			deliveryBillId : delivery_bill_id
		};
		$.ajax({
			type : "post",
			url : url,
			data : params,
			datatype : "json",
			success : function(json) {
				if(json && json.resultCode == 1){
					$("#del_box").toggle();
					layer.msg('签收成功',{time:1000});
					//检查订单是否结束
					if (json.isFinished == "1") {
						// 跳转订单列表页面
						setTimeout(function(){
							window.location.href = rootPath+"/wx/order/list?orderStatus=05";
						},1000);
					}else {
						// 刷新当前页
						setTimeout(function(){
							window.location.href = rootPath+"/wx/order/toConfirmSign?orderCode="+order_code;
						},1000);
					}
				}else{
					layer.msg('签收失败',{time:1000});
				}
			},
			error : function() {
				layer.msg('订单取消失败',{time:1000});
			}
		});
	});
	
	$("#btn_cancel_sign").click(function(){
		$("#del_box").toggle();
	});
	
	
});
</script>
</head>
<body style="background:#f5f5f5">
<c:set var="rootPath" value="<%=basePath %>"></c:set>
<c:set var="imgRootURL" value="<%=imgRootURL %>"></c:set>

<div class="overlay" style="display:none" id="del_box">
	<div class="msg_box">
		<div class="bd">
			<p>您确定要签收该笔记订单吗？</p>
		</div>
		<div class="bottom">
			<ul>
				<li>
					<a id="btn_cancel_sign" href="javascript:void()">取消</a><i></i>
				</li>
				<li>
					<a id="btn_confirm_sign" href="javascript:void(0)">确认</a>
				</li>
			</ul>
		</div>
	</div>
</div>

<div class="dd_hd">
	<h3>
    	<i><em><img src="${rootPath}/statics_wx/images/icon_114.png" /></em></i><span>卖家已发货</span>
    </h3>
</div>
<div class="address_part">
		<div class="address_middle">
			<div class="address_box">
				<i></i>
				<div class="address_box_con">
					<h2><strong>${order.receiverName }</strong><span>${order.receiverMobile }</span></h2>
					<p>${order.provinceName}${order.cityName}${order.areaName}${order.streetName}${order.address}</p>
				</div>
			</div>
		</div>
	</div>
	
	<c:forEach items="${deliveredList }" var="delivery">
		<div class="hd11">
	    	<h3 class="a1">物流单号：${delivery.deliveryCode } &nbsp;&nbsp;物流公司：${delivery.deliveryCompanyName }</h3>
	    </div>
		<div class="prd_list1">
			<ul>
		    	<li>
		        	<div class="box5">
		        		<c:forEach items="${delivery.deliveredProductList }" var="product"> 
		        			<div class="good_info11" style="margin:5px 5px;">
			                	<div class="pic">
			                    	<img src="${imgRootURL}/${product.imagePath}" />
			                    </div>
			                    <div class="item-info">
			                    	<h2>${product.productName }</h2>
			                        <h3>
			                        	<c:forEach items="${product.productSpecList }" var="spec">
			                        		${spec.specName }：${spec.specValue }<br/>
			                        	</c:forEach>
			                        </h3>
			                        <h4><strong>￥<em><sl:nformat num="${product.productPrice}" format=".00" type="2"/></em>
													  <sl:nformat num="${product.productPrice}" format=".00" type="3"/></strong><b>x${product.sendNum }</b>
									</h4>
			                    </div>
			                </div>
		        		</c:forEach>
		            </div>
		        </li>
		    </ul>
		    <div class="bottom">
				<div class="nav_bottom">
					<p>
						<input type="hidden"  id="order_code" value="${delivery.orderCode}"/>
						<input type="hidden"  id="delivery_bill_id" value="${delivery.id}"/>
						<input type="hidden"  id="delivery_code" value="${delivery.deliveryCode}"/>
						<c:if test="${delivery.signStatus == '02' }">
							<a href="javascript:void(0)" class="btn1">已签收</a>
						</c:if>
						<c:if test="${delivery.signStatus == '01' }">
							<a id="btn_order_sign" href="javascript:void(0)" class="btn2">签收</a>
						</c:if>
					</p>
				</div>
			</div>
		</div>
	</c:forEach>
	


</body>
</html>